{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### FactRuEval-2016 preprocess\n",
    "More info about dataset: https://github.com/dialogue-evaluation/factRuEval-2016"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "import warnings\n",
    "\n",
    "\n",
    "warnings.filterwarnings(\"ignore\")\n",
    "sys.path.append(\"../\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from modules.data.fre import fact_ru_eval_preprocess"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "dev_dir = \"/home/eartemov/ae/work/factRuEval-2016/devset/\"\n",
    "test_dir = \"/home/eartemov/ae/work/factRuEval-2016/testset/\"\n",
    "dev_df_path = \"/home/eartemov/ae/work/factRuEval-2016/dev.csv\"\n",
    "test_df_path = \"/home/eartemov/ae/work/factRuEval-2016/test.csv\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "43de7e40d1784421bb55921e2d0058f3",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(IntProgress(value=0, description='Process FactRuEval2016 dev set.', max=1519, style=ProgressSty…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "27617d0f776d4b37b6f893bcac517f24",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(IntProgress(value=0, description='Process FactRuEval2016 test set.', max=2715, style=ProgressSt…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "fact_ru_eval_preprocess(dev_dir, test_dir, dev_df_path, test_df_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>labels</th>\n",
       "      <th>text</th>\n",
       "      <th>cls</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>O O B_LOC O O O O O B_PER I_PER O O O O O</td>\n",
       "      <td>Сегодня в Москве на 40-й день после смерти Его...</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>O B_LOC I_LOC O O O O B_ORG O B_PER I_PER O O ...</td>\n",
       "      <td>К Кронштадтскому бульвару , где болельщика « С...</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>O O O O O O O O O O</td>\n",
       "      <td>И тишина ... Все прошло мирно и не столь массово</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>O O O O O O O O O O O O O</td>\n",
       "      <td>Правда , были задержания , но , как пояснили в...</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>O O O O O O O O O O</td>\n",
       "      <td>Одним словом , очередной « Русский марш » не с...</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                              labels  \\\n",
       "0          O O B_LOC O O O O O B_PER I_PER O O O O O   \n",
       "1  O B_LOC I_LOC O O O O B_ORG O B_PER I_PER O O ...   \n",
       "2                                O O O O O O O O O O   \n",
       "3                          O O O O O O O O O O O O O   \n",
       "4                                O O O O O O O O O O   \n",
       "\n",
       "                                                text    cls  \n",
       "0  Сегодня в Москве на 40-й день после смерти Его...  False  \n",
       "1  К Кронштадтскому бульвару , где болельщика « С...  False  \n",
       "2   И тишина ... Все прошло мирно и не столь массово   True  \n",
       "3  Правда , были задержания , но , как пояснили в...   True  \n",
       "4  Одним словом , очередной « Русский марш » не с...   True  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_csv(dev_df_path, sep=\"\\t\").head()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
